var switchTag = false; //切换正式与测试环境
if(switchTag) {
	var PATH = 'https://hrhdht.miyapay.com/';
	var Appid = 'wx2dac5f9f64a29966';
	var HR_KEY = '2a330818a0cc4823b78a968f55ba7504';
	var activeid = 'aaa'; //活动id
	var starttime = "2018-06-14 00:00:00"; //世界杯开始时间
	var channel = "hractive";
} else {
	var PATH = 'https://wxopentest.miyapay.com/';
	var Appid = 'wx2dac5f9f64a29966';
	var HR_KEY = '2a330818a0cc4823b78a968f55ba7504';
	var activeid = 'aaa'; //活动id
	var starttime = "2018-06-14 00:00:00"; //世界杯开始时间
	var channel = "hractive";
}
//  var Openid = 'o1vUMt77NwH5FmPKzcl5LfLs59nU2';
var Openid = sessionStorage.Openid;  
var AccessToken = sessionStorage.AccessToken; 
var nickname = sessionStorage.nickname;   
// var CODE = '0813Pj4a0adVUv1DSi3a0b4s4a03Pj4g';
var CODE = getQueryString("code") || "";
var _backUri = encodeURI(window.location);
var $loadingToast = $("#loadingToast");
/**
 * 时间秒数格式化
 * @param s 时间戳（单位：秒）
 * @returns {*} 格式化后的时分秒
 */
var sec_to_time = function(s) {
	var t;
	if(s > -1) {
		var hour = Math.floor(s / 3600);
		var min = Math.floor(s / 60) % 60;
		var sec = s % 60;
		if(hour < 10) {
			t = '0' + hour + ":";
		} else {
			t = hour + ":";
		}

		if(min < 10) {
			t += "0";
		}
		t += min + ":";
		if(sec < 10) {
			t += "0";
		}
		t += sec.toFixed(2);
	}
	return t;
}
//获得年月日      得到日期oTime    
function getMyDate(str) {
	var oDate = new Date(str),
		oYear = oDate.getFullYear(),
		oMonth = oDate.getMonth() + 1,
		oDay = oDate.getDate(),
		oHour = oDate.getHours(),
		oMin = oDate.getMinutes(),
		oSen = oDate.getSeconds(),
		oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay) + ' ' + getzf(oHour) + ':' + getzf(oMin) + ':' + getzf(oSen); //最后拼接时间    
	return oTime;
};
//补0操作    
function getzf(num) {
	if(parseInt(num) < 10) {
		num = '0' + num;
	}
	return num;
}
// 随机字符串
function _getRandomString(len) {
	var len = len;
	var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
	var maxPos = $chars.length;
	var pwd = '';
	for(i = 0; i < len; i++) {
		pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
	}
	return pwd;
}
/*获取openid*/
var _getOpenid = function(callback) {
	
	//lottery4EntityPrize("o1vUMt77NwH5FmPKzcl5LfLs59nU"); //华润世界杯分享抽实体物品
	//getWxUserMsg("o1vUMt77NwH5FmPKzcl5LfLs59nU"); //获取用户信息
	//queryHrActiveUser("o1vUMt77NwH5FmPKzcl5LfLs59nU"); //查询用户世界杯人物形象
	//hrActiveCountdown(); //获取倒计时
	return false;
	if(!sessionStorage.Openid || sessionStorage.Openid == undefined || sessionStorage.Openid == "undefined") {
		console.log("进入无session")
	if(!CODE) {
		  window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid='+Appid+'&redirect_uri='+_backUri+'&response_type=code&scope=snsapi_userinfo&state=STATE&component_appid=wx234a1eec53d323db#wechat_redirect';
	} else {
		var sign = md5("appid=" + Appid + "&code=" + CODE + "&key=" + HR_KEY).toUpperCase();
		var param = {
			'code': CODE,
			'appid': Appid,
			sign
		}

		$.ajax({
			type: "get",
			url: PATH + "WechatMsg/Notify/getOpenIdByHrAppid",
			data: param,
			dataType: "json",
			success: function(data) {

				console.log(data)
				if(data.code == 200) {
					Openid = data.data.openid;
					AccessToken = data.data.access_token;
					sessionStorage.setItem('Openid', Openid);
					sessionStorage.setItem('AccessToken', AccessToken);
					//lottery4EntityPrize(data.data); //华润世界杯分享抽实体物品
					//getWxUserMsg(data.data); //获取用户信息
					//queryHrActiveUser(data.data)
					//hrActiveCountdown(); //获取倒计时
					callback(data.data.openid);
				}
			}
		});
	}
}else{
		console.log("进入有session")
		callback(Openid);
	}
	// _getUserid(Openid);
	// _searchOrder();				
}
/*换取userid*/
function _getUserid(Openid) {
	userid = Openid;
	// var param = {
	// 	'wx_openid': Openid,
	// 	'channel': '',
	// 	'spreadcode': '',
	// 	'openid': '',
	// 	'cityCode': '',
	// 	'appid': '',
	// 	'tel': ''
	// }
	// $.ajax({
	// 	url: 'https://miyapay.com/lucky/h5!openid2Userid.action',
	// 	type: "get",
	// 	dataType: "json",
	// 	data: param,
	// 	success: function(data) {
	// 		if(data.result == 200) {
	// 			userid = data.data;
	// 		}
	// 	},
	// 	error: function(err) {
	// 		console.log(err);
	// 	}
	// });
}

/*
	华润世界杯分享抽实体物品
	nonce_str		是	10位随机字符串
	openId		    是	
	sign	    	是
*/
function lottery4EntityPrize(openid) {
	var nonce_str = _getRandomString(10)
	var sign = md5("nonce_str=" + nonce_str + "&openid=" + openid + "&key=" + HR_KEY).toUpperCase();
	var param = {
		openid,
		nonce_str,
		sign
	};
	$.ajax({
		url: PATH + 'WechatMsg/hractive/lottery4EntityPrize',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			console.log(data);
			if(parseInt(data.code)==200){
				if(data.data){
					$('.win2').show()
				}else{
					$('.win3').show()
				}
			}
		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	微信体外券线下核销
	appid	     string     是	
	cardid       string	    是	卡模板id
	couponid	 string  	是	体外券券码
	sign	      string	是	签名,拼接key值2a330818a0cc4823b78a968f55ba7504
*/
function consumeOffline(cardid, couponid) {
	var sign = md5("appid=" + Appid + "&cardid=" + cardid + "&couponid=" + couponid + "&key=" + HR_KEY).toUpperCase();
	var param = {
		"appid": Appid,
		cardid,
		couponid,
		sign
	};
	$.ajax({
		url: PATH + 'WechatMsg/hractive/WechatMsg/hractive/consumeOffline',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			console.log(data);
		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	获取用户信息
	openid	string	是	
	appid	string	是	
	sign	string	是	
*/
function getWxUserMsg(openid) {
	var sign = md5("access_token=" + AccessToken + "&appid=" + Appid + "&openid=" + openid + "&key=" + HR_KEY).toUpperCase();
	var param = {
		openid,
		"appid": Appid,
		"access_token":AccessToken,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/Notify/getWxUserMsg',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			//console.log(data);
			if(data.code == '200') {
				$('.nickname').html(data.data.nickname);
				$('.headimgurl').attr('src', data.data.headimgurl);
				sessionStorage.setItem('nickname', data.data.nickname);
			}else{
				showMessage(data.msg);
			}
		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	世界杯人物形象
	key	       参数类型	     是否必须	参数解释
	openid     string	      是	     用户openid
	activeid   string	      是	      活动编号
	name	   string	      是	      昵称
	sex	       int	          是	      性别1男2女
	sign	   string	      是	      签名,详见备注
	head	   string	      否	      头部图像编号
	socks	   string	      否	      袜子
	background  string	      否	      城市背景
	skin	   string	      否	      肤色
	num         string	      否	      球衣号码
	clothes	    string	      否	      衣服
	trousers	string	      否	      裤子
	shoes	     string	      否	       鞋子
	prop	    string	      否	       配饰
	type	    string	      否	       类型1、修改；2新增	
*/
function hrActiveUserDesign(openid, activeid, name, sex, head, socks, background, skin, num, clothes, trousers, shoes, prop, type) {
	background=setDefault(background);
	clothes=setDefault(clothes);
	head=setDefault(head);
	num=setDefault(num);
	prop=setDefault(prop);
	shoes=setDefault(shoes);
	socks=setDefault(socks);
	trousers=setDefault(trousers);
	// name = encodeURI(name);
	var sign = md5("activeid=" + activeid + "&background=" + background + "&clothes=" + clothes + "&head=" + head + "&num=" + num + "&openid=" + openid + "&prop=" + prop + "&sex=" + sex + "&shoes=" + shoes + "&skin=" + skin + "&socks=" + socks + "&trousers=" + trousers + "&type=" + type + "&key=" + HR_KEY).toUpperCase();
	// var sign = md5("activeid=" + activeid + "&background=" + setDefault(background) + "&clothes=" + setDefault(clothes) + "&head=" + setDefault(head) + "&name=" + name + "&num=" + setDefault(num) + "&openid=" + openid + "&prop=" + setDefault(prop) + "&sex=" + sex + "&shoes=" + setDefault(shoes) + "&skin=" + setDefault(skin) + "&socks=" + setDefault(socks) + "&trousers=" + setDefault(trousers) + "&type=" + type + "&key=" + HR_KEY).toUpperCase();
	var param = {
		openid,
		activeid,
		// name,
		sex,
		head,
		socks,
		background,
		skin,
		num,
		clothes,
		trousers,
		shoes,
		prop,
		type,
		sign
	}
	console.log(param);
	$loadingToast.show();
	$.ajax({
		url: PATH + 'WechatMsg/hractive/hrActiveUserDesign',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			//console.log(data);
			$loadingToast.hide();
			if(data.code == '200') {
				if(type == '2') {
					lotteryByRanNum(Openid); //保存成功。抽奖	
				} else {
					showMessage('保存成功')
				}

			}else{
				showMessage(data.msg)
			}
		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	抽奖送券
	activeid   string	是	活动编号
	appid	   string	是	
	openid	   string	是	用户编号
	sign	   string	是	签名,拼接key值2a330818a0cc4823b78a968f55ba7504
*/
function lotteryByRanNum(openid) {
	var sign = md5("activeid=" + activeid + "&appid=" + Appid + "&openid=" + openid + "&key=" + HR_KEY).toUpperCase();
	var param = {
		activeid,
		"appid": Appid,
		openid,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/hractive/lotteryByRanNum',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			$loadingToast.hide();
			console.log(data);
			if(data.code=='200'){
				if(data.data&&data.data.length>0){
					$('.win1 .coupons img').attr('src',data.data[0].logo_url);
					$('.win1 .name').text(data.data[0].coupon_name);
					$('.win1 .t').text(data.data[0].rule);
					$('.win1 .coupon_fee').text(data.data[0].coupon_fee)
					$('.win1').show();
				}else{
					$('.win3').show();
				}
				
			}
		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	查看我的奖品
	activeid   string	是	活动编号
	openid	   string	是	用户编号
	sign	   string	是	签名,拼接key值2a330818a0cc4823b78a968f55ba7504
*/
function queryMyCoupon(openid, fn) {
	var sign = md5("activeid=" + activeid + "&openid=" + openid + "&key=" + HR_KEY).toUpperCase();
	var param = {
		activeid,
		openid,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/hractive/queryMyCoupon',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			console.log(data);
			fn(data);
		},
		error: function(err) {
			console.log(err);
		}
	});
}
/*
	微信体外券领取（即活动兑换券）
	cardid	string	是	卡券的cardid
	channel	string	是	领取渠道
	count	int	    否	领取数量,不传默认1
	openid	string	是	用户openid
	sign	string	是	签名,拼接key值2a330818a0cc4823b78a968f55ba7504
*/
function getVoucher(openid, cardid) {
	var count = 1;
	var sign = md5("cardid=" + cardid + "&channel=" + channel + "&count=" + count + "&openid=" + openid + "&key=" + HR_KEY).toUpperCase();
	var param = {
		cardid,
		channel,
		count,
		openid,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/hractive/getVoucher',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			console.log(data);
		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	查询用户领取的体外券
	cardid	string	是	
	openid	string	是	
	status	string	是	状态；3领取未核销，4已核销，0查询全部
	sign	string	是
*/
function queryWxVoucher(openid) {
	var count = 1;
	var sign = md5("cardid=" + cardid + "&openid=" + openid + "&status=" + status + "&key=" + HR_KEY).toUpperCase();
	var param = {
		cardid,
		status,
		openid,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/hractive/queryWxVoucher',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			console.log(data);
		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	查询用户实物奖品
	cardid	string	是	
	openid	string	是	
	status	string	是	状态；3领取未核销，4已核销，0查询全部
	sign	string	是
*/
function queryEntityPrize(openid, fn) {
	var nonce_str = _getRandomString(10);
	var sign = md5("nonce_str=" + nonce_str + "&openid=" + openid + "&key=" + HR_KEY).toUpperCase();
	var param = {
		nonce_str,
		openid,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/hractive/queryEntityPrize',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			console.log(data);
			fn(data);
		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	获取倒计时
*/
function hrActiveCountdown() {
	var nonce_str = _getRandomString(10);
	var sign = md5("nonce_str=" + nonce_str + "&starttime=" + starttime + "&key=" + HR_KEY).toUpperCase();
	var param = {
		nonce_str,
		starttime,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/hractive/hrActiveCountdown',
		type: "get",
		dataType: "json",
		data: param,
		success: function(da) {
			//console.log(data);
			if(da.code == '200') {
				if(da.data) {
					if(da.data.length == 1) {
						$('.starttime .tag').eq(0).html(0);
						$('.starttime .tag').eq(1).html(da.data)
					} else {
						$('.starttime .tag').eq(0).html(da.data.split('')[0]);
						$('.starttime .tag').eq(1).html(da.data.split('')[1])
					}

				}

			}

		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*
	获取倒计时
*/
function hrActiveCountdown() {
	var nonce_str = _getRandomString(10);
	var sign = md5("nonce_str=" + nonce_str + "&starttime=" + starttime + "&key=" + HR_KEY).toUpperCase();
	var param = {
		nonce_str,
		starttime,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/hractive/hrActiveCountdown',
		type: "get",
		dataType: "json",
		data: param,
		success: function(da) {
			//console.log(data);
			if(da.code == '200') {
				if(da.data) {
					if(da.data.length == 1) {
						$('.starttime .tag').eq(0).html(0);
						$('.starttime .tag').eq(1).html(da.data)
					} else {
						$('.starttime .tag').eq(0).html(da.data.split('')[0]);
						$('.starttime .tag').eq(1).html(da.data.split('')[1])
					}

				}

			}

		},
		error: function(err) {
			console.log(err);
		}
	});
}

/*判断是否是会员*/
function _checkIsVip(token) { //根据openid判断是否为会员
	var param = {
		'openid': token,
		'appid': Appid
	}
	$loadingToast.show();
	$.ajax({
		url: PATH + 'WechatMsg/zhyTrade/userInfo',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			$loadingToast.hide();
			// alert(JSON.stringify(data));
			if(data.code == 200) {
				if(data.data == '1') {
					console.log("是会员")
				} else {
					//window.location.href = "https://w.url.cn/s/AKv46N3"
					//					console.log("不是会员")
				}
			}
		},
		error: function(err) {
			console.log(err);
		}
	});
}

var _init = function() {
	//_getOpenid();
	//_getUserid(Openid);

}();

/*function Tocomment() {
	$(".scroll ul").on("click", "li", function() {
		sessionStorage.trade_no = $(this).attr("trade_no");
		sessionStorage.shop_id = $(this).attr("shop_id");
		$(".page5").hide();
		$(".page3").show();
	})
}
*/
// saasid参数抓取
function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) return unescape(r[2]);
	return null;
}

//微信分享设置
function getWxJsApi(isShareGame) {

	var sign = 'appid=' + Appid + '&url=' + _backUri + '&key=' + HR_KEY;
	sign = md5(sign);
	sign = sign.toUpperCase();
	$loadingToast.show();
	$.ajax({
		url: PATH + 'WechatMsg/Notify/authJsApi',
		type: 'POST',
		data: {
			appid: Appid,
			url: _backUri,
			sign: sign
		},
		dataType: 'json',
		success: function(data) {
			console.log(data);
			var $data = data.data;
			wx.config({
				debug: false,
				appId: $data.appid,
				timestamp: $data.timestamp,
				nonceStr: $data.noncestr,
				signature: $data.signature,
				jsApiList: [
					"onMenuShareTimeline",
					"onMenuShareAppMessage"
				]
			});
			$loadingToast.hide();
			wx.ready(function() {
				var nickname = sessionStorage.nickname ? sessionStorage.nickname : '你的好友' ;
				var shareMask=$('.share');
				wx.onMenuShareTimeline({ //例如分享到朋友圈的API  
					title: '恭喜你！'+nickname+' 赠予你一套世界杯定制球服，速领！', // 分享标题
					link: 'http://wxopentest.miyapay.com/h5/mengniu/active.html', // 分享链接
					imgUrl: 'http://wxopentest.miyapay.com/h5/mengniu/img/shareicon.png?v2', // 分享图标
					success: function() {
						shareMask.hide();
						// 回调抽奖方法放到这里
						if(isShareGame) {
							lottery4EntityPrize(Openid);
						}
					},
					cancel: function() {}
				});

				wx.onMenuShareAppMessage({
					title: '恭喜你！'+nickname+' 赠予你一套世界杯定制球服，速领！', // 分享标题
					desc: '一起玩赚世界杯，勇闯俄罗斯就差你了。', // 分享描述
					link: 'http://wxopentest.miyapay.com/h5/mengniu/active.html', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: 'http://wxopentest.miyapay.com/h5/mengniu/img/shareicon.png?v2', // 分享图标
					type: '', // 分享类型,music、video或link，不填默认为link
					dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
					success: function() {
						shareMask.hide();
						// 回调抽奖方法放到这里
						if(isShareGame) {
							lottery4EntityPrize(Openid);
						}
					},
					cancel: function() {}
				});
			});

		}
	})

}
/*
	编辑实物奖励的用户信息
	address	string	是	用户详细地址（防止中文乱码，前端需做encode处理）
	mobile	string	是	手机号（防止中文乱码，前端需做encode处理）
	name	string	是	姓名
	openid	string	是	
	sign	string	是	签名,拼接key值2a330818a0cc4823b78a968f55ba7504
	address_code	string	是	省市县
*/
function updateEntityPrizeUser(address, mobile, name, openid, address_code, fn) {
	var sign = md5("address=" + address + "&address_code=" + address_code + "&mobile=" + mobile + "&name=" + name + "&openid=" + openid + "&key=" + HR_KEY).toUpperCase();
	var param = {
		address,
		mobile,
		name,
		openid,
		address_code,
		sign
	}
	$.ajax({
		url: PATH + 'WechatMsg/hractive/updateEntityPrizeUser',
		type: "get",
		dataType: "json",
		data: param,
		success: function(data) {
			console.log(data);
			if(data.code == '200') {
				fn(data);
			} else {
				showMessage(data.msg)
			}

		},
		error: function(err) {
			console.log(err);
		}
	});
}
'use strict';
(function($,window){ 
	//动态加载animate
	var loadStyles = function(url) {
		var hasSameStyle = false;
		var links = $('link');
		for(var i = 0;i<links.length;i++){
			if(links.eq(i).attr('href') == url){
				hasSameStyle = true;
				return
			}
		}

		if(!hasSameStyle){
			var link = document.createElement("link");
			link.type = "text/css";
			link.rel = "stylesheet";
			link.href = url;
			document.getElementsByTagName("head")[0].appendChild(link);
		}
    }

    loadStyles('css/animate.css');

	//显示提示信息    toast
	$.fn.toast = function(options){
		var $this = $(this);
		var _this = this;
		return this.each(function(){
			$(this).css({
				position:'relative'
			});
			var top = '';		//bottom的位置
			var translateInfo = ''; 	//居中和不居中时的tarnslate

		    var box = '';   //消息元素
		    var defaults = {
		    	position:  			  "absolute", 				//不是body的话就absolute
		    	animateIn:  		  "fadeIn",					//进入的动画
		    	animateOut: 		  "fadeOut",				//结束的动画
				padding:              "20px 40px",              //padding
				background:           "rgba(7,17,27,0.66)",     //背景色
				borderRadius:         "6px",                    //圆角
				duration:             3000,                     //定时器时间
				animateDuration: 	  500, 						//执行动画时间
				fontSize:             28,                   	//字体大小
				content:              "这是一个提示信息",       //提示内容
				color:                "#fff",                   //文字颜色
				top:            	  "80%",                	//bottom底部的位置    具体的数值 或者center  垂直居中
				zIndex:               1000001,                	//层级
				isCenter:   		  true, 					//是否垂直水平居中显示
				closePrev: 			  true, 					//在打开下一个toast的时候立即关闭上一个toast
		    }
		    
		    var opt = $.extend(defaults,options||{});
		    var t = '';
		  
			// setTimeout(function(){
			//   	box.addClass('show');
			// },10);

			top = opt.isCenter===true? '50%':opt.top;

			defaults.isLowerIe9 = function(){
				return (!window.FormData);
			}

			// translateY(-50%)
			// translateInfo = opt.isCenter===true? 'translate3d(-50%,0,0)':'translate3d(-50%,-50%,0)';

		    defaults.createMessage = function(){
				if(opt.closePrev){
					$('.cpt-toast').remove();
				}
				box = $("<span class='animated "+opt.animateIn+" cpt-toast'></span>").css({
					"position":opt.position,
					"padding":opt.padding,
					"background":opt.background,
					"font-size":opt.fontSize,
					"-webkit-border-radius":opt.borderRadius,
					"-moz-border-radius":opt.borderRadius,
					"border-radius":opt.borderRadius,
					"color":opt.color,
					"top":top,
					"z-index":opt.zIndex,
					"-webkit-transform":'translate3d(-50%,-50%,0)',
			        "-moz-transform":'translate3d(-50%,-50%,0)',
			        "transform":'translate3d(-50%,-50%,0)',
			        '-webkit-animation-duration':opt.animateDuration/1000+'s',
	    			'-moz-animation-duration':opt.animateDuration/1000+'s',
	    			'animation-duration':opt.animateDuration/1000+'s',
				}).html(opt.content).appendTo($this);
				defaults.colseMessage();
		    }

		    defaults.colseMessage = function(){
		    	var isLowerIe9 = defaults.isLowerIe9();
		    	if(!isLowerIe9){
			    	t = setTimeout(function(){
			    		box.removeClass(opt.animateIn).addClass(opt.animateOut).on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',function(){
			    			box.remove();
			    		});
			    	},opt.duration);
		    	}else{
		    		t = setTimeout(function(){
			    		box.remove();
			    	},opt.duration);
		    	}
		    }

		    defaults.createMessage();
		})
	};
})(jQuery,window); 


var showMessage = function(content,duration,isCenter,animateIn,animateOut){
	var animateIn = animateIn || 'fadeIn';
	var animateOut = animateOut || 'fadeOut';
	var content = content || '这是一个提示信息';
	var duration = duration || '3000';
	var isCenter = isCenter || false;
	$('body').toast({
		position:'fixed',
		animateIn:animateIn,
		animateOut:animateOut,
		content:content,
		duration:duration,
		isCenter:isCenter,
	});
}

/*
	设置默认值
*/ 
function setDefault(val){
	return (val =="undefined" || val == undefined)?'0':val
}